﻿#include "buttongroup.h"
#include "ui_buttongroup.h"
#include <QVector>
#include <QDebug>
ButtonGroup::ButtonGroup(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ButtonGroup)
{
    ui->setupUi(this);
}

ButtonGroup::~ButtonGroup()
{
    delete ui;
}

void ButtonGroup::ButtonInit()
{
    ui->startbtn->setImage(":/images/start-1.png",":/images/start-3.png",":/images/start-2.png");
    ui->playbtn->setImage(":/images/chupai_btn-1.png",":/images/chupai_btn-3.png",":/images/chupai_btn-2.png");
    ui->playbtn2->setImage(":/images/chupai_btn-1.png",":/images/chupai_btn-3.png",":/images/chupai_btn-2.png");
    ui->passbtn->setImage(":/images/pass_btn-1.png",":/images/pass_btn-3.png",":/images/pass_btn-2.png");
    ui->nobtn->setImage(":/images/buqiang-1.png",":/images/buqiang-3.png",":/images/buqiang-2.png");
    ui->onebtn->setImage(":/images/1fen-1.png",":/images/1fen-3.png",":/images/1fen-2.png");
    ui->twobtn->setImage(":/images/2fen-1.png",":/images/2fen-3.png",":/images/2fen-2.png");
    ui->threebtn->setImage(":/images/3fen-1.png",":/images/3fen-3.png",":/images/3fen-2.png");

    QVector<MyButton*> vec;
    vec<<ui->startbtn<<ui->playbtn<<ui->playbtn2<<ui->passbtn<<ui->nobtn<<ui->onebtn<<ui->twobtn<<ui->threebtn;
    for(auto i=vec.begin();i!=vec.end();i++)
    {
        (*i)->setFixedSize(90,45);
    }
    connect(ui->startbtn,&MyButton::clicked,this,&ButtonGroup::start);
    connect(ui->playbtn,&MyButton::clicked,this,&ButtonGroup::play);
    connect(ui->playbtn2,&MyButton::clicked,this,&ButtonGroup::play);
    connect(ui->passbtn,&MyButton::clicked,this,&ButtonGroup::pass);
    connect(ui->nobtn,&MyButton::clicked,this,[=](){
        emit betPoint(0);
    });
    connect(ui->onebtn,&MyButton::clicked,this,[=](){
        emit betPoint(1);
    });
    connect(ui->twobtn,&MyButton::clicked,this,[=](){
        emit betPoint(2);
    });connect(ui->threebtn,&MyButton::clicked,this,[=](){
        emit betPoint(3);
    });

}

void ButtonGroup::selectPanel(ButtonGroup::PanelType type,int point)
{
    ui->stackedWidget->setCurrentIndex(type);
    if(type==CallLord)
    {
        if(point==1)
        {
            ui->onebtn->setVisible(false);//隐藏1分按钮
        }
        else if(point==2)
        {
            ui->onebtn->setVisible(false);
            ui->twobtn->setVisible(false);
        }
    }

}

